package cn.wildfirechat.app.webhook.github.pojo;

import com.google.gson.Gson;

import java.util.Date;

//https://developer.github.com/v3/activity/events/types/#starevent
public class StarEvent {
    //The action performed. Can be created or deleted.
    public String action;
    public Date starred_at;
    public Repository repository;
    public Sender sender;

    public static StarEvent fromJson(String jsonStr) {
        return new Gson().fromJson(jsonStr, StarEvent.class);
    }

    public static void main(String[] args) {
        String starEvent1 = "{\"action\":\"deleted\",\"starred_at\":null,\"repository\":{\"id\":218795851,\"node_id\":\"MDEwOlJlcG9zaXRvcnkyMTg3OTU4NTE=\",\"name\":\"web-chat\",\"full_name\":\"wildfirechat/web-chat\",\"private\":false,\"owner\":{\"login\":\"wildfirechat\",\"id\":33191460,\"node_id\":\"MDEyOk9yZ2FuaXphdGlvbjMzMTkxNDYw\",\"avatar_url\":\"https://avatars0.githubusercontent.com/u/33191460?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/wildfirechat\",\"html_url\":\"https://github.com/wildfirechat\",\"followers_url\":\"https://api.github.com/users/wildfirechat/followers\",\"following_url\":\"https://api.github.com/users/wildfirechat/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/wildfirechat/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/wildfirechat/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/wildfirechat/subscriptions\",\"organizations_url\":\"https://api.github.com/users/wildfirechat/orgs\",\"repos_url\":\"https://api.github.com/users/wildfirechat/repos\",\"events_url\":\"https://api.github.com/users/wildfirechat/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/wildfirechat/received_events\",\"type\":\"Organization\",\"site_admin\":false},\"html_url\":\"https://github.com/wildfirechat/web-chat\",\"description\":\"Open source IM solution. \",\"fork\":false,\"url\":\"https://api.github.com/repos/wildfirechat/web-chat\",\"forks_url\":\"https://api.github.com/repos/wildfirechat/web-chat/forks\",\"keys_url\":\"https://api.github.com/repos/wildfirechat/web-chat/keys{/key_id}\",\"collaborators_url\":\"https://api.github.com/repos/wildfirechat/web-chat/collaborators{/collaborator}\",\"teams_url\":\"https://api.github.com/repos/wildfirechat/web-chat/teams\",\"hooks_url\":\"https://api.github.com/repos/wildfirechat/web-chat/hooks\",\"issue_events_url\":\"https://api.github.com/repos/wildfirechat/web-chat/issues/events{/number}\",\"events_url\":\"https://api.github.com/repos/wildfirechat/web-chat/events\",\"assignees_url\":\"https://api.github.com/repos/wildfirechat/web-chat/assignees{/user}\",\"branches_url\":\"https://api.github.com/repos/wildfirechat/web-chat/branches{/branch}\",\"tags_url\":\"https://api.github.com/repos/wildfirechat/web-chat/tags\",\"blobs_url\":\"https://api.github.com/repos/wildfirechat/web-chat/git/blobs{/sha}\",\"git_tags_url\":\"https://api.github.com/repos/wildfirechat/web-chat/git/tags{/sha}\",\"git_refs_url\":\"https://api.github.com/repos/wildfirechat/web-chat/git/refs{/sha}\",\"trees_url\":\"https://api.github.com/repos/wildfirechat/web-chat/git/trees{/sha}\",\"statuses_url\":\"https://api.github.com/repos/wildfirechat/web-chat/statuses/{sha}\",\"languages_url\":\"https://api.github.com/repos/wildfirechat/web-chat/languages\",\"stargazers_url\":\"https://api.github.com/repos/wildfirechat/web-chat/stargazers\",\"contributors_url\":\"https://api.github.com/repos/wildfirechat/web-chat/contributors\",\"subscribers_url\":\"https://api.github.com/repos/wildfirechat/web-chat/subscribers\",\"subscription_url\":\"https://api.github.com/repos/wildfirechat/web-chat/subscription\",\"commits_url\":\"https://api.github.com/repos/wildfirechat/web-chat/commits{/sha}\",\"git_commits_url\":\"https://api.github.com/repos/wildfirechat/web-chat/git/commits{/sha}\",\"comments_url\":\"https://api.github.com/repos/wildfirechat/web-chat/comments{/number}\",\"issue_comment_url\":\"https://api.github.com/repos/wildfirechat/web-chat/issues/comments{/number}\",\"contents_url\":\"https://api.github.com/repos/wildfirechat/web-chat/contents/{+path}\",\"compare_url\":\"https://api.github.com/repos/wildfirechat/web-chat/compare/{base}...{head}\",\"merges_url\":\"https://api.github.com/repos/wildfirechat/web-chat/merges\",\"archive_url\":\"https://api.github.com/repos/wildfirechat/web-chat/{archive_format}{/ref}\",\"downloads_url\":\"https://api.github.com/repos/wildfirechat/web-chat/downloads\",\"issues_url\":\"https://api.github.com/repos/wildfirechat/web-chat/issues{/number}\",\"pulls_url\":\"https://api.github.com/repos/wildfirechat/web-chat/pulls{/number}\",\"milestones_url\":\"https://api.github.com/repos/wildfirechat/web-chat/milestones{/number}\",\"notifications_url\":\"https://api.github.com/repos/wildfirechat/web-chat/notifications{?since,all,participating}\",\"labels_url\":\"https://api.github.com/repos/wildfirechat/web-chat/labels{/name}\",\"releases_url\":\"https://api.github.com/repos/wildfirechat/web-chat/releases{/id}\",\"deployments_url\":\"https://api.github.com/repos/wildfirechat/web-chat/deployments\",\"created_at\":\"2019-10-31T15:17:35Z\",\"updated_at\":\"2020-02-23T10:34:40Z\",\"pushed_at\":\"2020-02-17T01:53:42Z\",\"git_url\":\"git://github.com/wildfirechat/web-chat.git\",\"ssh_url\":\"git@github.com:wildfirechat/web-chat.git\",\"clone_url\":\"https://github.com/wildfirechat/web-chat.git\",\"svn_url\":\"https://github.com/wildfirechat/web-chat\",\"homepage\":\"http://docs.wildfirechat.cn\",\"size\":97998,\"stargazers_count\":18,\"watchers_count\":18,\"language\":\"JavaScript\",\"has_issues\":true,\"has_projects\":true,\"has_downloads\":true,\"has_wiki\":true,\"has_pages\":false,\"forks_count\":31,\"mirror_url\":null,\"archived\":false,\"disabled\":false,\"open_issues_count\":3,\"license\":{\"key\":\"mit\",\"name\":\"MIT License\",\"spdx_id\":\"MIT\",\"url\":\"https://api.github.com/licenses/mit\",\"node_id\":\"MDc6TGljZW5zZTEz\"},\"forks\":31,\"open_issues\":3,\"watchers\":18,\"default_branch\":\"master\"},\"organization\":{\"login\":\"wildfirechat\",\"id\":33191460,\"node_id\":\"MDEyOk9yZ2FuaXphdGlvbjMzMTkxNDYw\",\"url\":\"https://api.github.com/orgs/wildfirechat\",\"repos_url\":\"https://api.github.com/orgs/wildfirechat/repos\",\"events_url\":\"https://api.github.com/orgs/wildfirechat/events\",\"hooks_url\":\"https://api.github.com/orgs/wildfirechat/hooks\",\"issues_url\":\"https://api.github.com/orgs/wildfirechat/issues\",\"members_url\":\"https://api.github.com/orgs/wildfirechat/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/wildfirechat/public_members{/member}\",\"avatar_url\":\"https://avatars0.githubusercontent.com/u/33191460?v=4\",\"description\":\"北京野火无限网络科技有限公司--专注于即时通讯技术，提供优质可控的即时通讯能力\"},\"sender\":{\"login\":\"heavyrain2012\",\"id\":34463389,\"node_id\":\"MDQ6VXNlcjM0NDYzMzg5\",\"avatar_url\":\"https://avatars0.githubusercontent.com/u/34463389?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/heavyrain2012\",\"html_url\":\"https://github.com/heavyrain2012\",\"followers_url\":\"https://api.github.com/users/heavyrain2012/followers\",\"following_url\":\"https://api.github.com/users/heavyrain2012/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/heavyrain2012/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/heavyrain2012/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/heavyrain2012/subscriptions\",\"organizations_url\":\"https://api.github.com/users/heavyrain2012/orgs\",\"repos_url\":\"https://api.github.com/users/heavyrain2012/repos\",\"events_url\":\"https://api.github.com/users/heavyrain2012/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/heavyrain2012/received_events\",\"type\":\"User\",\"site_admin\":false}}";
        StarEvent deletedEvent = new Gson().fromJson(starEvent1, StarEvent.class);
        System.out.println(deletedEvent.action);

        String starEvent2 = "{\"action\":\"created\",\"starred_at\":\"2020-02-23T10:35:05Z\",\"repository\":{\"id\":218795851,\"node_id\":\"MDEwOlJlcG9zaXRvcnkyMTg3OTU4NTE=\",\"name\":\"web-chat\",\"full_name\":\"wildfirechat/web-chat\",\"private\":false,\"owner\":{\"login\":\"wildfirechat\",\"id\":33191460,\"node_id\":\"MDEyOk9yZ2FuaXphdGlvbjMzMTkxNDYw\",\"avatar_url\":\"https://avatars0.githubusercontent.com/u/33191460?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/wildfirechat\",\"html_url\":\"https://github.com/wildfirechat\",\"followers_url\":\"https://api.github.com/users/wildfirechat/followers\",\"following_url\":\"https://api.github.com/users/wildfirechat/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/wildfirechat/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/wildfirechat/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/wildfirechat/subscriptions\",\"organizations_url\":\"https://api.github.com/users/wildfirechat/orgs\",\"repos_url\":\"https://api.github.com/users/wildfirechat/repos\",\"events_url\":\"https://api.github.com/users/wildfirechat/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/wildfirechat/received_events\",\"type\":\"Organization\",\"site_admin\":false},\"html_url\":\"https://github.com/wildfirechat/web-chat\",\"description\":\"Open source IM solution. \",\"fork\":false,\"url\":\"https://api.github.com/repos/wildfirechat/web-chat\",\"forks_url\":\"https://api.github.com/repos/wildfirechat/web-chat/forks\",\"keys_url\":\"https://api.github.com/repos/wildfirechat/web-chat/keys{/key_id}\",\"collaborators_url\":\"https://api.github.com/repos/wildfirechat/web-chat/collaborators{/collaborator}\",\"teams_url\":\"https://api.github.com/repos/wildfirechat/web-chat/teams\",\"hooks_url\":\"https://api.github.com/repos/wildfirechat/web-chat/hooks\",\"issue_events_url\":\"https://api.github.com/repos/wildfirechat/web-chat/issues/events{/number}\",\"events_url\":\"https://api.github.com/repos/wildfirechat/web-chat/events\",\"assignees_url\":\"https://api.github.com/repos/wildfirechat/web-chat/assignees{/user}\",\"branches_url\":\"https://api.github.com/repos/wildfirechat/web-chat/branches{/branch}\",\"tags_url\":\"https://api.github.com/repos/wildfirechat/web-chat/tags\",\"blobs_url\":\"https://api.github.com/repos/wildfirechat/web-chat/git/blobs{/sha}\",\"git_tags_url\":\"https://api.github.com/repos/wildfirechat/web-chat/git/tags{/sha}\",\"git_refs_url\":\"https://api.github.com/repos/wildfirechat/web-chat/git/refs{/sha}\",\"trees_url\":\"https://api.github.com/repos/wildfirechat/web-chat/git/trees{/sha}\",\"statuses_url\":\"https://api.github.com/repos/wildfirechat/web-chat/statuses/{sha}\",\"languages_url\":\"https://api.github.com/repos/wildfirechat/web-chat/languages\",\"stargazers_url\":\"https://api.github.com/repos/wildfirechat/web-chat/stargazers\",\"contributors_url\":\"https://api.github.com/repos/wildfirechat/web-chat/contributors\",\"subscribers_url\":\"https://api.github.com/repos/wildfirechat/web-chat/subscribers\",\"subscription_url\":\"https://api.github.com/repos/wildfirechat/web-chat/subscription\",\"commits_url\":\"https://api.github.com/repos/wildfirechat/web-chat/commits{/sha}\",\"git_commits_url\":\"https://api.github.com/repos/wildfirechat/web-chat/git/commits{/sha}\",\"comments_url\":\"https://api.github.com/repos/wildfirechat/web-chat/comments{/number}\",\"issue_comment_url\":\"https://api.github.com/repos/wildfirechat/web-chat/issues/comments{/number}\",\"contents_url\":\"https://api.github.com/repos/wildfirechat/web-chat/contents/{+path}\",\"compare_url\":\"https://api.github.com/repos/wildfirechat/web-chat/compare/{base}...{head}\",\"merges_url\":\"https://api.github.com/repos/wildfirechat/web-chat/merges\",\"archive_url\":\"https://api.github.com/repos/wildfirechat/web-chat/{archive_format}{/ref}\",\"downloads_url\":\"https://api.github.com/repos/wildfirechat/web-chat/downloads\",\"issues_url\":\"https://api.github.com/repos/wildfirechat/web-chat/issues{/number}\",\"pulls_url\":\"https://api.github.com/repos/wildfirechat/web-chat/pulls{/number}\",\"milestones_url\":\"https://api.github.com/repos/wildfirechat/web-chat/milestones{/number}\",\"notifications_url\":\"https://api.github.com/repos/wildfirechat/web-chat/notifications{?since,all,participating}\",\"labels_url\":\"https://api.github.com/repos/wildfirechat/web-chat/labels{/name}\",\"releases_url\":\"https://api.github.com/repos/wildfirechat/web-chat/releases{/id}\",\"deployments_url\":\"https://api.github.com/repos/wildfirechat/web-chat/deployments\",\"created_at\":\"2019-10-31T15:17:35Z\",\"updated_at\":\"2020-02-23T10:35:05Z\",\"pushed_at\":\"2020-02-17T01:53:42Z\",\"git_url\":\"git://github.com/wildfirechat/web-chat.git\",\"ssh_url\":\"git@github.com:wildfirechat/web-chat.git\",\"clone_url\":\"https://github.com/wildfirechat/web-chat.git\",\"svn_url\":\"https://github.com/wildfirechat/web-chat\",\"homepage\":\"http://docs.wildfirechat.cn\",\"size\":97998,\"stargazers_count\":19,\"watchers_count\":19,\"language\":\"JavaScript\",\"has_issues\":true,\"has_projects\":true,\"has_downloads\":true,\"has_wiki\":true,\"has_pages\":false,\"forks_count\":31,\"mirror_url\":null,\"archived\":false,\"disabled\":false,\"open_issues_count\":3,\"license\":{\"key\":\"mit\",\"name\":\"MIT License\",\"spdx_id\":\"MIT\",\"url\":\"https://api.github.com/licenses/mit\",\"node_id\":\"MDc6TGljZW5zZTEz\"},\"forks\":31,\"open_issues\":3,\"watchers\":19,\"default_branch\":\"master\"},\"organization\":{\"login\":\"wildfirechat\",\"id\":33191460,\"node_id\":\"MDEyOk9yZ2FuaXphdGlvbjMzMTkxNDYw\",\"url\":\"https://api.github.com/orgs/wildfirechat\",\"repos_url\":\"https://api.github.com/orgs/wildfirechat/repos\",\"events_url\":\"https://api.github.com/orgs/wildfirechat/events\",\"hooks_url\":\"https://api.github.com/orgs/wildfirechat/hooks\",\"issues_url\":\"https://api.github.com/orgs/wildfirechat/issues\",\"members_url\":\"https://api.github.com/orgs/wildfirechat/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/wildfirechat/public_members{/member}\",\"avatar_url\":\"https://avatars0.githubusercontent.com/u/33191460?v=4\",\"description\":\"北京野火无限网络科技有限公司--专注于即时通讯技术，提供优质可控的即时通讯能力\"},\"sender\":{\"login\":\"heavyrain2012\",\"id\":34463389,\"node_id\":\"MDQ6VXNlcjM0NDYzMzg5\",\"avatar_url\":\"https://avatars0.githubusercontent.com/u/34463389?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/heavyrain2012\",\"html_url\":\"https://github.com/heavyrain2012\",\"followers_url\":\"https://api.github.com/users/heavyrain2012/followers\",\"following_url\":\"https://api.github.com/users/heavyrain2012/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/heavyrain2012/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/heavyrain2012/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/heavyrain2012/subscriptions\",\"organizations_url\":\"https://api.github.com/users/heavyrain2012/orgs\",\"repos_url\":\"https://api.github.com/users/heavyrain2012/repos\",\"events_url\":\"https://api.github.com/users/heavyrain2012/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/heavyrain2012/received_events\",\"type\":\"User\",\"site_admin\":false}}";
        StarEvent starredEvent = new Gson().fromJson(starEvent2, StarEvent.class);
        System.out.println(starredEvent.action);
    }
}
